package com.lagou.edu.controller;

import com.lagou.edu.service.IUserService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @Description TODO
 * @Classname UserController
 * @Date 2021/5/30 16:40
 * @Author ch'ien
 */

@RestController
@RequestMapping("/user")
public class UserController {


    @Reference
    private IUserService userServer;

    @GetMapping("/register/{email}/{password}/{code}")
    public int register(@PathVariable String email, @PathVariable String password, @PathVariable String code){

        System.out.println(userServer.register(email, password, code));
        return userServer.register(email, password, code);
    }

    @GetMapping("/isRegistered/{email}")
    public boolean isRegistered(@PathVariable String email){

        return userServer.isRegistered(email);
    }

    @GetMapping("/login/{email}/{password}")
    public String login(@PathVariable String email, @PathVariable String password, HttpServletResponse response){

        return userServer.login(email,password,response);
    }

    @GetMapping("/info/{token}")
    public String info(@PathVariable String token){

        return userServer.info(token);
    }

    @GetMapping("/testMsg")
    public String testMsg() throws InterruptedException {

        return userServer.testMsg();
    }
}
